import sklearn
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LinearRegression

# kmeans聚类分析-乳腺癌数据集
# # help帮助-默认有分页截断
# print(f"help(sklearn):\n{help(sklearn)}")
# dir帮助：dir() 可以列出一个模块或对象的所有属性和方法。
print(f"dir(sklearn):\n{dir(sklearn)}")

breast_data=datasets.load_breast_cancer()
x=breast_data.data
y=breast_data.target
train_x,test_x,train_y,test_y=train_test_split(x,y,test_size=0.2,random_state=42)
estimater_kmeans=KMeans(n_clusters=2,random_state=42)
estimater_kmeans.fit(train_x)
predicted_labels=estimater_kmeans.predict(test_x)

# pca(降维)-axes3d可视化-数据集白酒分析
wine_data=datasets.load_wine()
x=wine_data.data
y=wine_data.target
train_x,test_x,train_y,test_y=train_test_split(x,y,test_size=0.2,random_state=42)
estimater_pca=PCA(n_components=2,random_state=42)
estimater_pca.fit(train_x)
transformed_x=estimater_pca.transform(test_x)







